package com.douma;


public class Test {

    public static void main(String[] args) {
        move(3, 1, 2, 3);
    }

    public static void func(int a) {
        if (a <= 0) return;
        System.out.println("开始调用 func() 函数");
        func(a - 1);
    }


    // 递归求阶乘
    public long factorial(int n) {
        if (n <= 0) return 0;

        if (n == 1) return 1;

        return n * factorial(n - 1);
    }


    // 汉诺塔问题
    public static void move(int n, int one, int two, int three) {
        if (n == 0) return;

        move(n - 1, one, three, two);
        System.out.println(String.format("将 1 个盘子从 %d 移动到 %d", one, three));
        move(n - 1, two, one, three);
    }

    // 斐波那契数
    public int fib(int n) {

        if (n == 0) return 0;

        if (n == 1) return 1;

        return fib(n - 1) + fib(n - 2);
    }
}
